package com.xcity.pomelo.response;

import com.xcity.db.entity.Player;
import com.xcity.game.arena.ArenaUtils;
import com.xcity.game.arena.offline.ArenaDailyRewardTemplate;
import com.xcity.game.arena.offline.OfflineArenaHandler;
import com.xcity.game.common.PlayerPool;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;
import naga.x.util.StringUtils;

@PomeloMessage(type = Message.Type.RESPONSE)
public class OfflineArenaInfoResponse extends Response {
	
	public int rank;
	public String badge; // 徽章
	public int score;
	public int won, lost; // 胜利、失败次数
	public int honor; // 荣誉点数
	public int joyBeans; // 欢乐豆
	public int freeNum;
	public int cd; // 战斗cd
	public int clearCDStone;
	public int buyNumStone;
	public DailyReward reward;
	
	public static class DailyReward {
//		public long state; // 领奖倒计时（为0可领奖）
		public int gold;
		public int honor;
		DailyReward(/*long state, */ArenaDailyRewardTemplate reward) {
//			this.state = state;
			if (reward != null) {
				this.gold = reward.getGold();
				this.honor = reward.getHonor();
			}
		}
	}
	
	public OfflineArenaInfoResponse(int serial, Player player, int rank, String badge, OfflineArenaHandler handler) {
		super(serial);
		this.rank = rank;
		this.score = 0;//player.getPool().getIntValue(PlayerPool.PROPERTY_ARENA_SCORE);
		this.won = player.getPool().getIntValue(PlayerPool.PROPERTY_ARENA_WON_NUM);
		this.lost = player.getPool().getIntValue(PlayerPool.PROPERTY_ARENA_LOST_NUM);
		this.honor = player.getHonor();
		this.joyBeans = 0;
		this.badge = StringUtils.isNotEmpty(badge) ? badge : "";
		this.freeNum = ArenaUtils.getLeftJoinTimes(player);
		this.cd = ArenaUtils.getJoinCD(player);
		this.clearCDStone = ArenaUtils.clearCDCost;
		this.buyNumStone = ArenaUtils.getBuyTimesCostStone(player);
		this.reward = new DailyReward(/*-1L, */handler.findDailyReward(rank - 1));
	}

}
